package com.tanhua.server.controller;

import com.tanhua.server.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.GET;
import java.util.Map;

@RestController
@RequestMapping("/messages")
public class MessagesController {


    @Autowired
    private CommentService commentService;

    @GetMapping(value = "/likes",name = "查询对当前登录人圈子点赞的人")
    public ResponseEntity likes(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10")Integer pagesize
                                ){
        return commentService.queryLikesOrCommentsOrLoves(page,pagesize,1);
    }

    @GetMapping(value = "/comments",name = "查询对当前登录人圈子评论的人")
    public ResponseEntity comments(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10")Integer pagesize
    ){
        return commentService.queryLikesOrCommentsOrLoves(page,pagesize,2);
    }

    @GetMapping(value = "/loves",name = "查询对当前登录人圈子喜欢的人")
    public ResponseEntity loves(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10")Integer pagesize
    ){
        return commentService.queryLikesOrCommentsOrLoves(page,pagesize,3);
    }


    @PostMapping(value = "/contacts",name = "聊一下成为好友")
    public ResponseEntity contacts(@RequestBody Map param){
        Long friendId = Long.parseLong(param.get("userId").toString());
        return commentService.contacts(friendId);
    }
}
